﻿Imports System.Data.OleDb

Public Class rssList
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("learningConnectionString").ConnectionString)
        Dim SqlString As String = "SELECT Top 5 UserFirstName, UserLastName, ID, UserAvatarPicture FROM  UserContent Order By ID Desc"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text

        oleDbConn.Open()
        rptRSS.DataSource = cmd.ExecuteReader()
        rptRSS.DataBind()
        oleDbConn.Close()

    End Sub

    Protected Function GetPicture(ByVal input As Object)
        Dim data As String = input.ToString()
        Dim path As String = Request.Url.AbsoluteUri
        path = path.Replace("rssList.aspx", data)
        Return FormatForXML(path)

    End Function


    Protected Function GetLink(ByVal input As Object)
        Dim data As String = input.ToString()
        Dim path As String = Request.Url.AbsoluteUri
        path = path.Replace("rssList.aspx", "Detail.aspx?ID=" + data)
        Return FormatForXML(path)

    End Function

    Protected Function FormatForXML(ByVal input As Object)

        Dim data As String = input.ToString()
        data = data.Replace("&", "&amp;")
        data = data.Replace("""", "&quot;")
        data = data.Replace("'", "&apos;")
        data = data.Replace("<", "&lt;")
        data = data.Replace(">", "&gt;")

        Return data


    End Function

End Class